package models.common.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Transient;

import common.constants.ConfConst;
import common.constants.Constants;
import common.enums.ServiceType;
import common.utils.Security;

import play.db.jpa.Model;

/**
 * 用户授信额度明细
 * 
 * @description
 * 
 * @author fanghanyong
 * @createDate 2018年01月11日
 */

@Entity
public class t_user_credit_detail extends Model {

	/**
	 * 构造器
	 */
	public t_user_credit_detail() {

	}

	/**
	 * 
	 * @param time 生成时间
	 * @param user_id 持有人id
	 * @param user_name 持有人名称
	 * @param credit_limit_total 预授信总额度
	 * @param credit_granting_code 预授信号
	 * @param start_time 起始时间
	 * @param end_time 截止时间
	 * @param lender_id 放款人id
	 * @param lender_name 放款人名称
	 * @param financing_used_limit 融通已使用额度
	 * @param transfer_used_limit 已转让额度
	 * @param transferee_used_limit 已受让额度
	 * @param cleared_limit 已结清
	 * @param overdue_limit 已逾期
	 * @param usable_limit 可用
	 * @param service_order_no 
	 * @param remark
	 * @param credit_limit_id 所属授信
	 * @param parent_id 父级id
	 */
	public t_user_credit_detail(Date time, long user_id, String user_name,
			double credit_limit_total, String credit_granting_code,
			Date start_time, Date end_time, long lender_id, String lender_name,
			double financing_used_limit, double transfer_used_limit,
			double transferee_used_limit, double cleared_limit,
			double overdue_limit, double usable_limit, String service_order_no,
			String remark, long credit_limit_id, long parent_id) {
		super();
		this.time = time;
		this.user_id = user_id;
		this.user_name = user_name;
		this.credit_limit_total = credit_limit_total;
		this.credit_granting_code = credit_granting_code;
		this.start_time = start_time;
		this.end_time = end_time;
		this.lender_id = lender_id;
		this.lender_name = lender_name;
		this.financing_used_limit = financing_used_limit;
		this.transfer_used_limit = transfer_used_limit;
		this.transferee_used_limit = transferee_used_limit;
		this.cleared_limit = cleared_limit;
		this.overdue_limit = overdue_limit;
		this.usable_limit = usable_limit;
		this.service_order_no = service_order_no;
		this.remark = remark;
		this.credit_limit_id = credit_limit_id;
		this.parent_id = parent_id;
	}
   /**
    * 
    * @param time 时间 
    * @param user_id 融通用户的id
    * @param user_name 融通用户名称
    * @param credit_limit_total 授信总额度
    * @param financing_used_limit 融通使用额度
    * @param lender_id 放款人
    * @param lender_name 放款人名称
    * @param overdue_limit 预期额度
    */
	public t_user_credit_detail(Date time, Long user_id, String user_name,double credit_limit_total,double financing_used_limit,long lender_id, String lender_name,double overdue_limit){
		this.time = time;
		this.user_id = user_id;
		this.user_name = user_name;
		this.credit_limit_total = credit_limit_total;
		this.lender_id = lender_id;
		this.lender_name = lender_name;
		this.overdue_limit = overdue_limit;
		this.financing_used_limit = financing_used_limit;
	}
	
	/**
    * 
    * @param time 时间 
    * @param user_id 融通用户的id
    * @param user_name 融通用户名称
    * @param credit_limit_total 授信总额度
    * @param cleared_limit 已结清
    * @param lender_id 放款人
    * @param lender_name 放款人名称
    * @param overdue_limit 预期额度
    * @param usable_limit 调整额度
    * @param credit_granting_code 授信编号
    * @param remark 融通还款
    * @param credit_limit_id 用户授信表初始id
    */
	public t_user_credit_detail(Date time, Long user_id, String user_name,double credit_limit_total,double cleared_limit,long lender_id, String lender_name,double overdue_limit, String credit_granting_code, double usable_limit, String remark, long credit_limit_id){
		this.time = time;
		this.user_id = user_id;
		this.user_name = user_name;
		this.credit_limit_total = credit_limit_total;
		this.lender_id = lender_id;
		this.lender_name = lender_name;
		this.overdue_limit = overdue_limit;
		this.cleared_limit = cleared_limit;
		this.credit_granting_code = credit_granting_code;
		this.usable_limit = usable_limit;
		this.remark = remark;
		this.credit_limit_id = credit_limit_id;
	}
	
	/** 时间 */
	public Date time;

	/** 持有人用户id */
	public long user_id;
	
	@Transient
	public String userSignId;
	public String getUserSignId () {
		
		return Security.addSign(this.user_id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}

	/** 持有人 */
	public String user_name;

	/** 授信总额度 */
	public double credit_limit_total;

	/** 授信编号 */
	public String credit_granting_code;

	/** 授信起始日期 */
	public Date start_time;

	/** 授信截止时间 */
	public Date end_time;

	/** 放款人id */
	public long lender_id;
	
	@Transient
	public String lenderSignId;
	public String getLenderSignId () {
		
		return Security.addSign(this.lender_id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}

	/** 放款人名称 */
	public String lender_name;

	/** 已用融通额度 */
	public double financing_used_limit;

	/** 已转让总额度 */
	public double transfer_used_limit;

	/** 已受让总额度 */
	public double transferee_used_limit;

	/** 已结清总额度 */
	public double cleared_limit;

	/** 逾期额度 */
	public double overdue_limit;

	/** 可用授信额度 */
	public double usable_limit;

	/** 业务流水号 */
	public String service_order_no;

	/** 摘要 */
	public String remark;

	/** 用户授信表id */
	public long credit_limit_id;
	
	@Transient
	public String signId;
	public String getSignId () {
		
		return Security.addSign(this.credit_limit_id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}

	/** 父级id */
	public long parent_id;
	
	@Transient
	public String parentSignId;
	public String getParentSignId () {
		
		return Security.addSign(this.parent_id, Constants.BID_ID_SIGN, ConfConst.ENCRYPTION_KEY_DES);
	}

	/** 备用 */
	public String reserve;
	
	

}